package cn.initcap.designpattern.pattern.behavioral.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * 访问者模式
 *
 * @author initcap
 * @date Created in 2018/11/1 PM11:05.
 */
public class Test {

    public static void main(String[] args) {
        List<BaseCourse> baseCourseList = new ArrayList<>();

        FreeBaseCourse freeCourse = new FreeBaseCourse();
        freeCourse.setName("JVM");

        CodingBaseCourse codingCourse = new CodingBaseCourse();
        codingCourse.setName("设计模式");
        codingCourse.setPrice(258);

        baseCourseList.add(freeCourse);
        baseCourseList.add(codingCourse);

        for (BaseCourse baseCourse : baseCourseList) {
            baseCourse.accept(new SearchVisitor());
        }

        for (BaseCourse baseCourse : baseCourseList) {
            baseCourse.accept(new ViewVisitor());
        }
    }

}
